package xyz.zdsoft.user_info_manage_module.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import xyz.zdsoft.common.utils.Result;
import xyz.zdsoft.user_info_manage_module.pojo.*;
import xyz.zdsoft.user_info_manage_module.service.Impl.StudentInfoManagementServiceImpl;

import javax.annotation.Resource;

/**
 * 学生信息管理
 * @author 以风
 */
@Api(tags = "学生信息管理")
@RestController
@RequestMapping("/api/admin/studentInfoManagement")
public class StudentInfoManagementController {
    @Resource
    private StudentInfoManagementServiceImpl studentInfoManagementService;

    @ApiOperation(value = "获取班级信息分页列表（查询、分页、重置）")
    @PostMapping("/getClassInfoPage")
    public Result<IPage<ClassInfo>> getClassInfoPage(ClassInfoParameter classInfoParameter){
        IPage<ClassInfo> page = new Page<>(classInfoParameter.getCurrent(),classInfoParameter.getSize());
        IPage<ClassInfo> classInfoIPage = studentInfoManagementService.getClassInfoPage(page,classInfoParameter);
        return Result.ok().message("获取班级信息分页列表成功").data(classInfoIPage);
    }

    @ApiOperation(value = "新增班级")
    @PostMapping("/insertClass")
    public Result insertClass(InsertClassParameter insertClassParameter){
        Result result = studentInfoManagementService.insertClass(insertClassParameter);
        return result;
    }

    @ApiOperation(value = "编辑")
    @PostMapping("/editClass")
    public Result editClass(EditClassInfoParameter editClassInfoParameter){
        Result result = studentInfoManagementService.editClassInfo(editClassInfoParameter);
        return result;
    }

    @ApiOperation(value = "学员明细分页列表(查询、分页、重置)")
    @PostMapping("/getStudentsSubsidiary")
    public Result<IPage<StudentsSubsidiary>> getStudentsSubsidiaryPage(StudentsSubsidiaryParameter studentsSubsidiaryParameter){
        IPage<StudentsSubsidiary> page = new Page<>(studentsSubsidiaryParameter.getCurrent(),studentsSubsidiaryParameter.getSize());
        IPage<StudentsSubsidiary> subsidiaryIPage = studentInfoManagementService.getStudentsSubsidiaryPage(page,studentsSubsidiaryParameter);
        return Result.ok().message("获取学员明细分页列表成功").data(subsidiaryIPage);
    }

    @ApiOperation(value = "学员明细-新增")
    @PostMapping("/insertStudent")
    public Result insertStudent(InsertStudentSubsidiary insertStudentSubsidiary){
        Result result = studentInfoManagementService.insertStudent(insertStudentSubsidiary);
        return result;
    }

    @ApiOperation(value = "学员明细-编辑（学员信息维护）")
    @PostMapping("/editStudentsSubsidiary")
    public Result EditStudentsSubsidiary(EditStudentSubsidiary editStudentSubsidiary){
        Result result = studentInfoManagementService.editStudentsSubsidiary(editStudentSubsidiary);
        return result;
    }

    @ApiOperation(value = "学员明细-删除（批量删除）")
    @GetMapping("/deleteStudents")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id",value = "班级id",required = true),
            @ApiImplicitParam(name = "studentsId",value = "学生id数组",required = true)
    })
    public Result deleteStudents(long id,Long[] studentsId){
        Result result = studentInfoManagementService.deleteStudents(id,studentsId);
        return result;
    }

}
